/*
 * Copyright 2009 (c) Patrick Pietens.
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */
package indigo.model
{
	import flash.events.Event;

	/**
	 * The <code>ModelLocator</code> class is a singleton 
	 * <code>HistoryManager</code> which holds the state of your application 
	 * and is one of the most important parts of your Indigo application. 
	 * The state of your application is  the data upon which its operates. 
	 * When a model changes its state, it notifies its associated 
	 * <code>Views</code> so  they can refresh.
	 * 
	 * <p>The state can be referenced and set from anywhere in your Indigo 
	 * application by using the <code>getProperty</code> and 
	 * <code>setProperty</code> shortcuts. Although it is recommend to use 
	 * <code>Commands</code> to set your application's state.</p>
	 *  
	 * @example
	 * <listing version="3.0">
	 * </listing>
	 * 
	 * @playerversion Flash 9
	 * @langversion ActionScript 3.0
	 * 
	 * @see getProperty
	 * @see setProperty
	 * @see watchProperty
	 * @see unwatchProperty
	 * @see undo
	 * @see redo
	 * @see BindableObject
	 */
	final public dynamic class ApplicationModel extends BindableObject
	{
		/**
		 * Reference to the ModelLocator
		 */
		private static var INSTANCE:ApplicationModel = null;


		/**
		 * Constructor
		 * 
		 */
		public function ApplicationModel( singleton:SingletonEnforcer )
		{
			log( "Instantiating" );
			super();
		}


		/**
		 * Returns the instance of the ModelLocator. When there is no reference it
		 * will create a new instance.
		 * @return	Instance of the ModelLocator
		 * 
		 */
		public static function getInstance():ApplicationModel
		{
			if ( INSTANCE == null ) INSTANCE = new ApplicationModel( new SingletonEnforcer );
			return INSTANCE;
		}


		/**
		 * @inheritDoc
		 * 
		 */
		override public function dispose( event:Event = null ):void
		{
			super.dispose();
			INSTANCE = null;
		}
	}
}
internal class SingletonEnforcer
{
}